package com.example.pfa;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

public class MonumentosInfo extends DialogFragment{
	
	static MonumentosInfo newInstance(CharSequence titulo, int idFoto, int idTexto){
		MonumentosInfo fragment = new MonumentosInfo();
        Bundle args = new Bundle();
        args.putCharSequence("titulo", titulo);
        args.putInt("imagen", idFoto);
        args.putInt("texto", idTexto);
        fragment.setArguments(args);
        return fragment;
    }
	
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
    	
    	CharSequence titulo = getArguments().getCharSequence("titulo");
    	int idFoto = getArguments().getInt("imagen");
    	int idTexto = getArguments().getInt("texto");
    	
    	AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    	
    	View view = getActivity().getLayoutInflater().inflate(R.layout.monumentos_info, null);
    	
    	ImageView imagen = (ImageView) view.findViewById(R.id.imageView1);
    	TextView texto = (TextView) view.findViewById(R.id.textView1);
    	
    	imagen.setImageResource(idFoto);    	
    	texto.setText(idTexto);
  
    	builder.setView(view)
    		.setTitle(titulo)
    		.setPositiveButton("Visitar", new DialogInterface.OnClickListener() {
	           public void onClick(DialogInterface dialog, int id) {	        	   
	        	   ((MainActivity)getActivity()).doVisitarClick();	        	   
	           }
       		})
       		.setNegativeButton("Volver", new DialogInterface.OnClickListener() {
	           public void onClick(DialogInterface dialog, int id) {	               
	        	   ((MainActivity)getActivity()).doVolverClick();
	           }
    		});
    	return builder.create();
    }
}
